<?php
if($_SERVER['SERVER_ADDR'] == '127.0.0.1' || $_SERVER['SERVER_NAME'] == 'localhost'){
        ### LOCAL CONNECTION ###
        $server   = "localhost";
        $username = "root";
        $password = "root";
        $database = "clientInfo";       
}else{
        ### REMOTE CONNECTION ####
        $server   = "h50mysql61.secureserver.net";
        $username = "cotcintranet";
        $password = "COTC123pwd";
        $database = "cotcintranet";       
}
 
$l  = mysql_connect ($server , $username , $password);
$db = mysql_select_db($database);
        
if(!$l){
	echo "Error occured.";
	exit();
}

// domain where the intranet is being hosted at
// used for logout link and user re-direction
$domain = "http://clients.catonthecouchproductions.com/";

// use for SQL validation and to prevent injection
// use: escape('field');
if(!function_exists('escape')){
	function escape($var) {
		$tmp = trim($_POST[$var]);
		if(get_magic_quotes_gpc())
		$tmp = stripslashes($tmp);
		
		return mysql_real_escape_string($tmp);
	}
}
// convert minutes
if(!function_exists('toMinutes')){
	function toMinutes($in){
		if(strpos($in,'.')!==false)  # hours as decimal number
			return round($in*60);
		elseif(strpos($in,':')!==false) {# HH:MM format
			list($h,$m) = explode(':',$in,2);
			return ($h*60)+$m;
		}
		else return (int) $in;  # minutes
	}
}
// set default timezone
date_default_timezone_set('America/New_York');
?>
